package com.example.springboot28.mapper;


import com.example.springboot28.bean.Department;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

//指定这是一个操作数据库的mapper
@Mapper
@Component(value = "DepartmentMapper")
public interface DepartmentMapper {

    @Select("select * from department where id=#{id}")
    public Department getDeptById(Integer id);

    @Delete("delete from department where id=#{id}")
    public int deleteDeptById(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into department(department_name) values(#{departmentName})")
    public void insertDept(Department department);

    @Update("update department set department_name=#{departmentName} where id=#{id}")
    public int updateDept(Department department);
}
